package com.kdtech.analyse.video;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

import com.kdtech.crawler.CrawlHTML;
import com.kdtech.entity.crawler.UrlMeta;
import com.kdtech.entity.data.NewsMeta;
import com.kdtech.analyse.AnalyseNews;
import com.kdtech.utils.DateUtils;
import com.kdtech.utils.NumberUtils;
import com.kdtech.utils.RegexUtils;
import com.kdtech.utils.StringUtils;

/**
 * <电视台 - 台州电视台> 解析类
 *
 * @author KK
 *
 */
public class YwcityAnalyse implements AnalyseNews {

	
	public boolean isDetailPage(String url) {
		String[] regex = {
				"http://v.ywcity.cn/folder[0-9]+/.*folder[0-9]+/[0-9]{4}/[0-9]{2}/[0-9]{4}-[0-9]{2}-[0-9]*.html",
				};
		return RegexUtils.matchAny(url,regex);
	}

	
	public NewsMeta parserHtml(UrlMeta urlMeta) {
		if (urlMeta.getHtml() == null) {
		}
		String htmltxt = urlMeta.getHtml();
		String url = urlMeta.getUrl();

		String title = null;
		Long date = null;
		String desc = null;
		String dateStr = null;
		String commnetNum = null;
		String clickNum = null;
		String updateUrl = null;
		Document doc = Jsoup.parse(htmltxt);
		title = doc.select("div.tvie_content>h1").text();
		if(StringUtils.isBlank(title))
			title =   doc.select("div#seeall_c h1").text();
		dateStr = doc.select("div.tvie_content_info").text();
//		desc =    doc.select("div#vBOX2 div.mx div.fl div#vifo div.ifo2").text();
//		clickNum =  doc.select("div#CNT div.box div.news_content p#acticle_info").text();
//		updateUrl = doc.select("").attr("src");
//		if (StringUtils.isNotBlank(clickNum)){
//			clickNum = StringUtils.substringBetween(clickNum, "查看: ", "次");
//		}
		date = DateUtils.matchDate(dateStr);
			NewsMeta news = new NewsMeta();
			news.setUrl(url);
			news.setType(2);
			news.setTitle(StringUtils.trimSpace(title));

			news.setDate(date);
			return news;

	}

	
	public NewsMeta Update(NewsMeta meta) {
		return null;
	}

	

	
}
